//
//  PicturesimageView.m
//  知乎日报
//
//  Created by 陈明光 on 2019/9/5.
//  Copyright © 2019 陈明光. All rights reserved.
//

#import "PicturesimageView.h"
@interface PicturesimageView()
@property(nonatomic,strong)UILabel *titleLabel;
@end
@implementation PicturesimageView
-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        //改变图片显示的模式
        self.contentMode=UIViewContentModeScaleAspectFill;
        
        //初始化字体
        self.titleLabel=[UILabel new];
        [self addSubview:self.titleLabel];
        //设置字体颜色
        self.titleLabel.textColor=[UIColor whiteColor];
        //设置字体位置,自适应高度
        self.titleLabel.sd_layout.centerXEqualToView(self).rightSpaceToView(self, 25).leftSpaceToView(self, 25).bottomSpaceToView(self, 35).autoHeightRatio(0);
    }
    return self;
}
-(void)setModel:(PicturesModel *)model{
    _model=model;
    [self sd_setImageWithURL:[NSURL URLWithString:model.image]];
    self.titleLabel.text=model.title;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
